<template>
  <div id="adminList">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="user_name" label="姓名" width="280"/>
      <el-table-column prop="create_time" label="注册日期" width="280"/>
      <el-table-column prop="city" label="地址" width="280"/>
      <el-table-column prop="admin" label="权限" fixed="right" align="left"/>
    </el-table>
    <div class="pageNext">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        :page-size="15"
        layout="total, prev, pager, next"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
  import api from '@/api/center'
  import store from '@/store'

  export default {
    data() {
      return {
        currentPage: 1,//当前页
        total: 0,//总数量
        tableData: [
          {
            user_name: '',
            create_time: '',
            city: '',
            admin: ''
          }
        ]
      }
    },
    mounted: function () {
      let params = {
        limit: 10
      };
      api.queryAllAdmin(params).then(res => {
        this.tableData = res.data;
      });
      api.queryAdminCount().then(res => {
        if (res.status === 1) {
          this.total = res.count;
        }
      });
    },
    methods: {
      handleCurrentChange(val) {
        let params = {
          limit: 10,
          offset: this.currentPage * 10
        };
        api.queryAllAdmin(params).then(res => {
          this.tableData = res.data;
        });
      }
    }
  }
</script>
<style lang="stylus" scoped>
  .pageNext {
    position relative
    top 10px
    width 100%
  }
</style>
